package dao.impl;

import dao.DeptDao;
import org.apache.ibatis.session.SqlSession;
import pojo.Dept;
import utils.MyBatisUtil;

import java.util.List;

public class DeptDaoimpl implements DeptDao {
    public List<Dept> findAll(Dept dept) {
        //TODO
        return MyBatisUtil.getSqlSession().getMapper(DeptDao.class).findAll(dept);
    }

    @Override
    public int DeleteDeptById(Integer id) {
       SqlSession session=MyBatisUtil.getSqlSession();
        int result=session.getMapper(DeptDao.class).DeleteDeptById(id);
        session.commit();
        return result;
    }

    @Override
    public Dept findByid(Integer id) {
        return MyBatisUtil.getSqlSession().getMapper(DeptDao.class).findByid(id);
    }

    @Override
    public int UpdateDept(Dept dept) {
        SqlSession session=MyBatisUtil.getSqlSession();
        int result=session.getMapper(DeptDao.class).UpdateDept(dept);
        session.commit();
        return result;
    }

    @Override
    public int addDept(Dept dept) {
        SqlSession session=MyBatisUtil.getSqlSession();
        int result=session.getMapper(DeptDao.class).addDept(dept);
        session.commit();
        return result;
    }
}
